<?php
include('TopSdk.php');
$c = new TopClient;
$c->appkey = '12584922';
$c->secretKey = 'b9298679627ec351899aa3aa8487e7fd';
$c->format = "json";

/*
$req = new ItemsSearchRequest;
$req->setFields("num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume,has_discount,num, is_prepay, promoted_service, ww_status, list_time");

$req->setNicks("威朗尼服饰旗舰店");
$req->setPageNo(1);
$req->setPageSize(100);

$req->setQ("title");
$req->setCid(34341);
$req->setProps("pid1:vid1;pid2:vid2");
$req->setOrderBy("popularity:desc");  //排序 price（价格）, delist_time（下架时间）, seller_credit（卖家信用）,popularity(人气)。如按价格升序排列表示为：price:asc。新增排序字段：volume（最近成交量）

$req->setWwStatus("true");    
$req->setPostFree("true");
$req->setIs3D("true");
$req->setStartScore(1);
$req->setEndScore(2);
$req->setStartVolume(100);
$req->setEndVolume(200);
$req->setOneStation("true");
$req->setIsCod("true");
$req->setIsMall("true");
$req->setIsPrepay("true");
$req->setGenuineSecurity("true");
$req->setPromotedService("2");
$req->setStuffStatus("new");
$req->setStartPrice(10);
$req->setEndPrice(120);
$req->setAuctionFlag("true");
$req->setAutoPost("true");
$req->setHasDiscount("true");
$req->setIsXinpin("true");
*/


$req = new TaobaokeItemsConvertRequest;
$req->setFields("num_iid,title,nick,pic_url,price,click_url,commission,ommission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume");
$req->setNumIids('13993129107');
$req->setPid(31014990); //淘宝联盟（阿里妈妈）PID
$req->setIsMobile("false"); //如果要生成手机页面的淘宝客链接，选择 true；网页版选择 false
 
$resp = $c->execute($req);
$res = object2Array($resp);

echo '<pre>';
  var_dump($res);
echo '</pre>';
    function object2Array($d){
        if (is_object($d)){
            $d = get_object_vars($d);
        }

        if(is_array($d)){
            return array_map(__FUNCTION__, $d);
        }else{
            return $d;
        }
}
